const statusArray = [
    { value: '0' , label: '草稿' },
    { value: '1' , label: '待审核' },
    { value: '2' , label: '已审核' },
    { value: '3' , label: '已生效' },
    { value: '4' , label: '待生效' },
    { value: '5' , label: '已失效' },
    { value: '6' , label: '已停用' },
]


// 筛选值
export const ReturnSelectOptions =  (data:any, value: any)=>{
    const {
        useOrgList, //使用组织
        customerTypeList, //客户类别
        customerGroupList, //客户分组类别
        create_user_name,customer, name, number, use_org
    } = data

    // 使用组织
    if (value == 'use_org_id' && useOrgList) {
        return useOrgList.map((item:any)=>{
            return { value: `${item.uid}`, label: item.name }
        })
    }

    // 策略下的 使用组织
    if (value == 'use_org_id' && use_org) {
        return use_org.map((item:any)=>{
            return { value: `${item.use_org_id}`, label: item.use_org_name }
        })
    }

    // 策略下的 策略名称
    if (value == 'name' && name) {
        return name.map((item:any)=>{
            return { value: `${item.name}`, label: item.name }
        })
    }

    // 策略下的 策略编号
    if (value == 'number' && number) {
        return number.map((item:any)=>{
            return { value: `${item.number}`, label: item.number_str }
        })
    }

    // 策略下的 策略创建人
    if (value == 'create_user_name' && create_user_name) {
        return create_user_name.map((item:any)=>{
            return { value: `${item.create_user_name}`, label: item.create_user_name }
        })
    }

    // 是否启用
    if (value == 'is_enable') {
        return [
            { value: 0, label: '否' },
            { value: 1, label: '是' },
        ]
    }
    // 规则类型
    if (value == 'type') {
        return [
            // { value: '0' , label: '满金额折扣' },
            // { value: '1' , label: '满数量折扣' },
            // { value: '2' , label: '满金额+数量折扣' },
            // { value: '3' , label: '指定产品满金额赠' },
            // { value: '4' , label: '指定产品满数量赠' },
            { value: '1' , label: '指定产品满数量赠' },
        ]
    }
    // 状态
    if (value == 'status') {
        return statusArray
    }
    // 优先级
    if (value == 'level') {
        let list = []
        for (let index = 0; index < 10; index++) {
            list.push({ value: `${index + 1}`, label: `${index + 1}级` })
        }
        return list
    }
    // 客户
    if(value == 'customer_uid' && customer) {
        return customer.map((item:any)=>{
            return { value: `${item.customer_uid}`, label: item.customer_name }
        })
    }
    // 客户类别
    if(value == 'cust_type_id' && customerTypeList) {
        return customerTypeList.map((item:any)=>{
            return { value: `${item.uid}`, label: item.name }
        })
    }
    // 客户分组
    if(value == 'primary_group' && customerGroupList) {
        return customerGroupList.map((item:any)=>{
            return { value: `${item.uid}`, label: item.name }
        })
    }

    return []
}

// 状态 tag
export const ReturnnStatus = (value: string | number, type = 'type')=>{

    let obj:any = {}

    // 失败、拒绝、停用 danger
    // 成功 success
    // 草稿 warning
    // 待 ''
    switch (Number(value)) {
        case 0:
            obj = {  label: '草稿', type: 'warning' }
            break;
        case 1:
            obj = {  label: '待审核', type: '' }
            break;
        case 2:
            obj = {  label: '已审核', type: 'success' }
            break;
        case 3:
            obj = {  label: '已生效', type: 'success' }
            break;
        case 4:
            obj = {  label: '待生效', type: '' }
            break;
        case 5:
            obj = {  label: '已失效', type: 'success' }
            break;
        case 6:
            obj = {  label: '已停用', type: 'danger' }
            break;
        default:
            obj = {  label: '创建中', type: 'info' }
            break;
    }

    return type == 'type' ? obj.type : obj.label
}

/**
 * @草稿箱
 */
export const GiveIndexSearch = [
    {  label: '策略编号', prop: 'number', type: 'select', multiple: true },
    // {  label: '策略名称', prop: 'name', type: 'select', multiple: true },
    {  label: '策略类型', prop: 'type', type: 'select', multiple: true },
    {  label: '策略状态', prop: 'status', type: 'select', multiple: true },
    // {  label: '使用组织', prop: 'use_org_id', type: 'select', multiple: true },
    {  label: '客户', prop: 'customer_uid', type: 'select', multiple: true },
    {  label: '生效时间', prop: 'effective_date', type: 'time' },
    {  label: '创建人', prop: 'create_user_name', type: 'select', multiple: true },
]

export const GiveIndexCloums = [
    {  label: '策略编号', prop: 'number', type: 'custom', width: '140' },
    // {  label: '策略名称', prop: 'name', type: '', width: '200' },
    {  label: '客户', prop: 'customer_name', type: ''},
    {  label: '策略类型', prop: 'type', type: 'custom', width: '150' },
    {  label: '策略状态', prop: 'status', type: 'custom', width: '100' },
    {  label: '生效时间', prop: 'effective_date', type: 'custom' },
    // {  label: '使用组织', prop: 'use_org_name', type: '', width: '200' },
    // {  label: '优先级', prop: 'level', type: 'custom', width: '100' },
]


/**
 * @折扣赠品设置创建
 */

export const CreateBaseForm = [
    {  label: '规则名称', prop: 'name', type: 'input', multiple: false, disabled: false},
    // {  label: '使用组织', prop: 'use_org_id', type: 'orgSelect', multiple: false, disabled: false},
    {  label: '生效时间', prop: 'effective_date', type: 'time', multiple: false, disabled: false},
    {  label: '是否启用', prop: 'is_enable', type: 'select', multiple: false, disabled: false},
    {  label: '规则类型', prop: 'type', type: 'select', multiple: false, disabled: false},
]
export const ScopeCloums = [
    { label: '信用对象', prop: 'customer_id' , required: true },
    { label: '客户编码', prop: 'customer_number', required: false },
    { label: '币别', prop: 'currency_id', width: '100' , required: true },
    { label: '信用额度', prop: 'credit_amount', width: '100' , required: true},
    { label: '信用状态', prop: 'credit_status', width: '140' , required: true },
    { label: '检查规则', prop: 'check_role_id', width: '140' , required: true},
]

/**
 * @详情
 */

export const DetailBase = [
    {  label: '规则名称', prop: 'name' },
    // {  label: '优先级', prop: 'level_str' },
    {  label: '生效时间', prop: 'effective_date' },
    {  label: '是否启用', prop: 'is_enable_str' },
    {  label: '规则类型', prop: 'type_str' },
]
export const DetailCloums = [
    { label: '信用对象', prop: 'customer_name' , type: '' },
    { label: '客户编码', prop: 'customer_number', required: false },
    { label: '币别', prop: 'currency_name', width: '100' , type: '' },
    { label: '信用额度', prop: 'credit_amount', width: '140' , type: 'custom'},
    { label: '信用状态', prop: 'credit_status', width: '140' , type: 'custom' },
    { label: '检查规则', prop: 'check_role_name', width: '200' , type: ''},
]
